package com.example.walled_houses.controller;


import com.example.walled_houses.entity.Opinion;
import com.example.walled_houses.entity.User;
import com.example.walled_houses.service.OpinionService;
import com.example.walled_houses.utils.UserHolder;
import com.example.walled_houses.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chengtaoxie
 * @since 2023-10-26
 */
@CrossOrigin
@Api(tags = "意见信息接口")
@RestController
@RequestMapping("/opinion")
public class OpinionController {



    @Resource
    private OpinionService opinionService;

    @ApiOperation("增加意见信息")
    @PostMapping("/addOpinion")
    public Result addOpinion(@RequestBody Opinion opinion){
        return opinionService.addOpinion(opinion);
    }

    @ApiOperation("删除意见信息")
    @DeleteMapping("deleteOpinion/{opinionId}")
    public Result deleteOpinion(@PathVariable Integer opinionId){
        return opinionService.deleteOpinion(opinionId);
    }

    @ApiOperation("分页查询意见信息")
    @GetMapping("/getOpinion/{currentPage}")
    public Result getOpinion(@PathVariable Integer currentPage){
        return opinionService.getOpinion(currentPage);
    }

    @ApiOperation("修改意见信息")
    @PutMapping("/updateOpinion")
    public Result updateOpinion(@RequestBody Opinion opinion){
        return opinionService.updateOpinion(opinion);
    }

}

